package com.ysx.admin.controller;

import com.ysx.admin.pojo.AdUser;
import com.ysx.admin.service.AdUserService;
import com.ysx.admin.vo.AdUserVo;
import com.ysx.common.pojo.Result;
import com.ysx.core.controller.AbstractCoreController;
import com.ysx.exception.ToutiaoException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
* <p>
* 管理员用户信息表 控制器</p>
* @author ljh
* @since 2021-09-07
*/
@Api(value="管理员用户信息表",tags = "登录管理")
@RestController
@RequestMapping("/admin")
@Slf4j
public class AdUserController extends AbstractCoreController<AdUser> {

    private AdUserService adUserService;

    //注入
    @Autowired
    public AdUserController(AdUserService adUserService) {
        super(adUserService);
        this.adUserService=adUserService;
    }

    @PostMapping("/login")
    @ApiOperation("登录管理员系统成功签发token令牌")
    public Result<Map<String,Object>> loginSystemReturnToken(@RequestBody AdUserVo adUserVo) throws ToutiaoException {
        log.debug("获得的登录信息{},{}"+adUserVo.getId(),adUserVo.getPassword());
        Map<String,Object> map = adUserService.loginSystemReturnToken(adUserVo);
        return Result.ok(map);
    }

}

